05. Exercise: XML

Exercise: XML

Given the below Java classes, your goal is to write XML that you would use to represent the Java object created using the following code fragment:

new CarRecords(List.of(
    new Car("Beetle", "Volkswagen", 1963),
    new Car("Miller-Meteor", "Cadillac", 1959)
));

CarRecords.java

import java.util.List;

public class CarRecords {
    private List<Car> records;

    public CarRecords() {}

    public CarRecords(List<Car> records) { 
      this.records = records;    
    }

    //getters and setters omitted
}

Car.java

public class Car {
    private String name;
    private String make;
    private int year;

    public Car() {  }

    public Car(String name, String make, int year) {
        this.name = name;
        this.make = make;
        this.year = year;
    }

    //getters and setters omitted
}